Technote PR 03 | July 1987 |
Some printers (usually those that are shared between many users, like the LaserWriter) can provide the names of the users who are printing and the documents that are being printed to others interested in using the printer.
If the chosen printer uses a document name, the Printing Manager gets the name from the frontmost window's title. If there is no front window, or if the window's title is empty, the Printing Manager defaults to "unknown."
This method was chosen because it works most transparently to applications; however, it won't work if your application doesn't display windows when printing (for instance, many applications that use windows for their documents do not open their documents when printing in response to a Finder "Print" command).
As a general solution to this problem, you can put up a window containing a message like "Press Cmd-. to cancel printing", and give it the document's title. If the window is one that doesn't have a title bar (like dBoxProc), this title will not be displayed. MacApp takes this approach. If for some reason you don't want to put up a visible window, you can create a tiny window and hide it behind the menu bar: for instance, global coordinates of (1,1,2,2). Make sure you use a plainDBox, so that no title will be drawn (otherwise, in the unlikely case that a user is using a Macintosh II with two stacked screens, main screen on the bottom, the title might be visible on the upper screen).
Since the Printing Manager checks the name at PrValidate time, call PrValidate after PrCloseDoc and before the next PrOpenDoc, if you want unique names.
A number of applications set the document name in the print record directly.
You should not do this because a) not all printers support this field, and b)
none are guaranteed to support it in the future. (Apple does not guarantee that
internal fields of the Printing Manager's data structures will remain the same;
the Printing Manager is targeted for substantial internal change!)
Further Reference:
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help